package com.hong.spring.beanfactory;

import com.hong.spring.common.entity.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Auther: csh
 * @Date: 2020/7/8 19:28
 * @Description:测试factoryBean
 */
public class FactoryBeanTest implements FactoryBean<User> {
    public User getObject() throws Exception {
        return new User();
    }

    public Class <?> getObjectType() {
        return User.class;
    }

    public boolean isSingleton() {
        return true;
    }

    public static void main(String[] args) {
        BeanFactory bf = new ClassPathXmlApplicationContext("beanfactory/applicationfile-factorybean.xml");
        User user = (User)bf.getBean("userFactory");
        System.out.println(user);
    }

}
